const routerDict = {
  Main: () => import('@/views/Main'),
  login: () => import('@/views/login/login.vue'),
  gather: () => import('@/views/gather/gather'),
  mouldCenter: () => import('@/views/mould/mould-center/mould-center'),
  siteManage: () => import('@/views/mould/site-manage/site-manage'),
  mouldExport: () => import('@/views/mould/mould-export/mould-export'),
  userManage: () => import('@/views/supervise/user-manage/user-manage'),
  roleManage: () => import('@/views/supervise/role-manage/role-manage'),
  documentAuthor: () => import('@/views/supervise/document-author/document-author'),
  deployCenter: () => import('@/views/deploy/deploy'),
  databaseSearch: () => import('@/views/database/database-search/database-search'),
  databaseCount: () => import('@/views/database/database-count/database-count'),
  logCenter: () => import('@/views/log/log'),
  monitorCenter: () => import('@/views/monitor/monitor'),
  mouldSetting: () => import('@/views/mould/mould-setting/mould-setting'),
  siteSetting: () => import('@/views/mould/site-setting/site-setting'),
  deploySetting: () => import('@/views/deploy/deploy-setting'),
  userSetting: () => import('@/views/supervise/user-setting/user-setting'),
  roleSetting: () => import('@/views/supervise/role-setting/role-setting'),
  setTask: () => import('@/views/gather/set-task/set-task'),
  error404: () => import('@/views/error/404'),
  error403: () => import('@/views/error/403'),
  error500: () => import('@/views/error/500')
}
/**
 * @description 路由过滤实例化
 * @param {Object} routerData
 * @param {Array} routers
 * @todo 递归调用函数封装,功能开发完毕后处理
 */
const assignRouter = (routerData, routers = []) => {
  routerData.forEach(item => {
    const menu = Object.assign({}, item)
    menu.component = routerDict[menu.component]
    if (item.children) assignRouter(item.children, (menu.children = []))
    routers.push(menu)
  })
  return routers
}

export default assignRouter
